#include <iostream>
#include <list>
#include <vector>
//
// Created by lingzhitech on 25-9-23.
//
int main() {
    int val = 42; // value we'll look for
    // result will denote the element we want if it's in vec, or vec.cend() if not
    std::vector<int> vec{1, 2, 3, 4, 5, 42};
    auto result = std::find(vec.cbegin(), vec.cbegin() + vec.size(), val);
    // report the result
    std::cout << "The value " << val
    << (result == vec.cend()
    ? " is not present" : " is present") << std::endl;


    std::list<std::string> lst{"abc", "a value", "table"};
    std::string val2 = "a value"; // value we'll look for
    // this call to find looks through string elements in a list
    auto result2 = find(lst.cbegin(), lst.cend(), val2);
    std::cout << "The value " << val2
        << (result2 == lst.cend()
                ? " is not present"
                : " is present") << std::endl;

    int ia[] = {27, 210, 12, 47, 109, 83};
    int val3 = 83;
    // int* result3 = std::find(std::begin(ia), std::end(ia), val3);
    int n = 6;
    auto result3 = std::find(ia + 1, ia + n, val3);
    std::cout << "The value " << val3
        << (result3 == ia + n
                ? " is not present"
                : " is present") << std::endl;
}